Run AppleScript command, application command
The Run command can function as an AppleScript command or an application command.The AppleScript Run command acts on script objects; it executes statements other than handler and property definitions in script object definitions.
The application Run command launches an application if it's not already running. The application must be on a local or mounted volume. If the application is already running, then the effect of the Run command depends
on the application. Some applications are not affected; others, such as the Scriptable Text Editor, repeat their startup procedures each time they receive
a Run command.APPLESCRIPT COMMAND SYNTAX
run [ scriptObjectVariable ]APPLICATION COMMAND SYNTAX
run [ referenceToApplication ]PARAMETERS
- scriptObjectVariable
A variable identifier whose value is a script object. This parameter is optional if the Run command is used within
an appropriate Tell statement.
Class: Script- referenceToApplication
A reference of the formapplication
nameString (see "Notes"). This parameter is optional if the Run command is used within an appropriate Tell statement.
Class: ReferenceRESULT
The AppleScript Run command returns the result, if any, returned by the specified script object's Run handler.The application Run command doesn't return a result.
EXAMPLES
run application "Scriptable Text Editor"tell application "Scriptable Text Editor" run end tellNOTES
To specify the name (nameString) of an application to run, use a string of the form"Disk:Folder1:Folder2:...:ApplicationName"
; for details, see "References to Applications," which begins on page 146. You can also specify a string with only an application name ("ApplicationName"). In this case, if the application
is not already running, AppleScript attempts to find the application in the current directory.AppleScript sends an implicit Run command whenever it begins to execute a Tell statement whose target is an application that is not already open. This can cause problems with applications such as Scriptable Text Editor that normally perform specific tasks on startup, such as opening a new window. To launch an application without invoking its usual startup behavior, use the Launch command as described on page 105. For information about using the Run and Launch commands with script applications, see "Calling a Script Application,"which begins on page 251.
For information about Run handlers, see "Run Handlers," which begins on page 243. For information about using the Run command with script objects, see Chapter 9, "Script Objects."